home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1996 March / Amiga-CD 1996 #3.iso / pd-software / mui_3.1 / developer / c / examples / boopsidoor.c < prev    next >
C/C++ Source or Header  |  1996-01-19  |  4KB  |  138 lines

  1. /*
  2. ** This program needs at least V39 include files !
  3. */
  4.  
  5. #include "demo.h"
  6.  
  7. #include "gadgets/colorwheel.h"
  8. #include "intuition/icclass.h"
  9. #include "intuition/gadgetclass.h"
  10.  
  11.  
  12. /*
  13. ** Gauge object macro to display colorwheels
  14. ** hue and saturation values.
  15. */
  16.  
  17. #define InfoGauge GaugeObject,\
  18.     GaugeFrame    , \
  19.     MUIA_Background  , MUII_BACKGROUND,\
  20.     MUIA_Gauge_Max   , 16384,\
  21.     MUIA_Gauge_Divide, 262144,\
  22.     MUIA_Gauge_Horiz , TRUE,\
  23.     End
  24.  
  25.  
  26. int main(int argc,char *argv[])
  27. {
  28.     struct Library *ColorWheelBase;
  29.     APTR app,window,Wheel,Hue,Sat;
  30.  
  31.     init();
  32.  
  33.     if (!(ColorWheelBase = OpenLibrary("gadgets/colorwheel.gadget",0)))
  34.         fail(NULL,"colorwheel boopsi gadget not available\n");
  35.  
  36.     app = ApplicationObject,
  37.         MUIA_Application_Title      , "BoopsiDoor",
  38.         MUIA_Application_Version    , "$VER: BoopsiDoor 12.9 (21.11.95)",
  39.         MUIA_Application_Copyright  , "©1992/93, Stefan Stuntz",
  40.         MUIA_Application_Author     , "Stefan Stuntz",
  41.         MUIA_Application_Description, "Show a boopsi colorwheel with MUI.",
  42.         MUIA_Application_Base       , "BOOPSIDOOR",
  43.  
  44.         SubWindow, window = WindowObject,
  45.             MUIA_Window_Title, "BoopsiDoor",
  46.             MUIA_Window_ID   , MAKE_ID('B','O','O','P'),
  47.  
  48.             WindowContents, VGroup,
  49.  
  50.                 Child, ColGroup(2),
  51.                     Child, Label("Hue:"       ), Child, Hue = InfoGauge,
  52.                     Child, Label("Saturation:"), Child, Sat = InfoGauge,
  53.                     Child, RectangleObject,MUIA_Weight,0,End, Child, ScaleObject, End,
  54.                     End,
  55.  
  56.                 Child, Wheel = BoopsiObject,  /* MUI and Boopsi tags mixed */
  57.  
  58.                     GroupFrame,
  59.  
  60.                     MUIA_Boopsi_ClassID  , "colorwheel.gadget",
  61.  
  62.                     MUIA_Boopsi_MinWidth , 30, /* boopsi objects don't know */
  63.                     MUIA_Boopsi_MinHeight, 30, /* their sizes, so we help   */
  64.  
  65.                     MUIA_Boopsi_Remember , WHEEL_Saturation, /* keep important values */
  66.                     MUIA_Boopsi_Remember , WHEEL_Hue,        /* during window resize  */
  67.  
  68.                     MUIA_Boopsi_TagScreen, WHEEL_Screen, /* this magic fills in */
  69.                     WHEEL_Screen         , NULL,         /* the screen pointer  */
  70.  
  71.                     GA_Left     , 0,
  72.                     GA_Top      , 0, /* MUI will automatically     */
  73.                     GA_Width    , 0, /* fill in the correct values */
  74.                     GA_Height   , 0,
  75.  
  76.                     ICA_TARGET  , ICTARGET_IDCMP, /* needed for notification */
  77.  
  78.                     WHEEL_Saturation, 0, /* start in the center */
  79.  
  80.                     End,
  81.                 End,
  82.             End,
  83.         End;
  84.  
  85.     if (!app)
  86.     {
  87.         if (ColorWheelBase) CloseLibrary(ColorWheelBase);
  88.         fail(app,"Failed to create Application.");
  89.     }
  90.  
  91.  
  92. /*
  93. ** you can react on every boopsi notification
  94. ** event as on any other MUI attribute.
  95. */
  96.  
  97.     DoMethod(Wheel,MUIM_Notify,WHEEL_Hue       ,MUIV_EveryTime,Hue,4,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  98.     DoMethod(Wheel,MUIM_Notify,WHEEL_Saturation,MUIV_EveryTime,Sat,4,MUIM_Set,MUIA_Gauge_Current,MUIV_TriggerValue);
  99.  
  100.  
  101.     DoMethod(window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  102.  
  103.  
  104. /*
  105. ** This is the ideal input loop for an object oriented MUI application.
  106. ** Everything is encapsulated in classes, no return ids need to be used,
  107. ** we just check if the program shall terminate.
  108. ** Note that MUIM_Application_NewInput expects sigs to contain the result
  109. ** from Wait() (or 0). This makes the input loop significantly faster.
  110. */
  111.  
  112.     set(window,MUIA_Window_Open,TRUE);
  113.  
  114.     {
  115.         ULONG sigs = 0;
  116.  
  117.         while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  118.         {
  119.             if (sigs)
  120.             {
  121.                 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  122.                 if (sigs & SIGBREAKF_CTRL_C) break;
  123.             }
  124.         }
  125.     }
  126.  
  127.     set(window,MUIA_Window_Open,FALSE);
  128.  
  129.  
  130.  
  131. /*
  132. ** shut down.
  133. */
  134.  
  135.     if (ColorWheelBase) CloseLibrary(ColorWheelBase);
  136.     fail(app,NULL);
  137. }
  138.